# eric7.Project.ProjectBaseBrowser

Module implementing the baseclass for the various project browsers.

### Global Attributes

None

### Classes

ProjectBaseBrowser | Baseclass implementing common functionality for the various project browsers.

### Functions

None

## ProjectBaseBrowser

Baseclass implementing common functionality for the various project browsers.

### Signals

closeSourceWindow(str)
  emitted to close a source file

### Derived from

Browser

### Class Attributes

None

### Class Methods

None

### Methods

ProjectBaseBrowser | Constructor
__checkHookKey | Private method to check a hook key.
__modelRowsInserted | Private slot called after rows have been inserted into the model.
_collapseAllDirs | Protected slot to handle the 'Collapse all directories' menu action.
_collapseAllFiles | Protected slot to handle the 'Collapse all files' menu action.
_completeRepopulateItem | Protected slot to handle the completeRepopulateItem signal.
_configure | Protected method to open the configuration dialog.
_connectExpandedCollapsed | Protected method to connect the expanded and collapsed signals.
_contextMenuRequested | Protected slot to show the context menu.
_copyToClipboard | Protected method to copy the path of an entry to the clipboard.
_createPopupMenus | Protected overloaded method to generate the popup menus.
_deleteDirectory | Protected method to delete the selected directory from the project data area.
_disconnectExpandedCollapsed | Protected method to disconnect the expanded and collapsed signals.
_expandAllDirs | Protected slot to handle the 'Expand all directories' menu action.
_initHookMethods | Protected method to initialize the hooks dictionary.
_initMenusAndVcs | Protected slot to initialize the menus and the Vcs interface.
_keyboardSearchType | Protected method to check, if the item is of the correct type.
_newProject | Protected slot to handle the newProject signal.
_prepareRepopulateItem | Protected slot to handle the prepareRepopulateItem signal.
_projectClosed | Protected slot to handle the projectClosed signal.
_projectOpened | Protected slot to handle the projectOpened signal.
_removeDir | Protected method to remove a (single) directory from the project.
_removeFile | Protected method to remove a file or files from the project.
_renameFile | Protected method to rename a file of the project.
_selectEntries | Protected method to select entries based on their VCS status.
_selectSingleItem | Protected method to select a single item.
_setItemRangeSelected | Protected method to set the selection status of a range of items.
_setItemSelected | Protected method to set the selection status of an item.
_showContextMenu | Protected slot called before the context menu is shown.
_showContextMenuBack | Protected slot called before the context menu is shown.
_showContextMenuDir | Protected slot called before the context menu is shown.
_showContextMenuDirMulti | Protected slot called before the context menu is shown.
_showContextMenuMulti | Protected slot called before the context menu (multiple selections) is shown.
_showProjectInFileManager | Protected slot to show the path of the project in a file manager application.
addHookMethod | Public method to add a hook method to the dictionary.
addHookMethodAndMenuEntry | Public method to add a hook method to the dictionary.
currentDirectory | Public method to determine the directory of the currently selected entry.
currentItem | Public method to get a reference to the current item.
expandItemsByName | Public method to expand items given their names.
getExpandedItemNames | Public method to get the file/directory names of all expanded items.
removeHookMethod | Public method to remove a hook method from the dictionary.
selectFile | Public method to highlight a node given its filename.
selectFileLine | Public method to highlight a node given its filename.
selectLocalDirEntries | Public slot to handle the select local directories context menu entries.
selectLocalEntries | Public slot to handle the select local files context menu entries.
selectVCSDirEntries | Public slot to handle the select VCS directories context menu entries.
selectVCSEntries | Public slot to handle the select VCS files context menu entries.

### Static Methods

None

#### ProjectBaseBrowser (Constructor)

ProjectBaseBrowser(project, filterType, parent=None)

Constructor

project (Project)
  reference to the project object
filterType (str)
  filter string for file types
parent (QWidget)
  parent widget of this browser

#### ProjectBaseBrowser.__checkHookKey

__checkHookKey(key)

Private method to check a hook key.

key (str)
  key of the hook to check

Raises KeyError:
  raised to indicate an invalid hook

#### ProjectBaseBrowser.__modelRowsInserted

__modelRowsInserted(_parent, _start, _end)

Private slot called after rows have been inserted into the model.

_parent (QModelIndex)
  parent index of inserted rows (unused)
_start (int)
  start row number (unused)
_end (int)
  end row number (unused)

#### ProjectBaseBrowser._collapseAllDirs

_collapseAllDirs()

Protected slot to handle the 'Collapse all directories' menu action.

#### ProjectBaseBrowser._collapseAllFiles

_collapseAllFiles()

Protected slot to handle the 'Collapse all files' menu action.

#### ProjectBaseBrowser._completeRepopulateItem

_completeRepopulateItem(name)

Protected slot to handle the completeRepopulateItem signal.

name (str)
  relative name of file item to be repopulated

#### ProjectBaseBrowser._configure

_configure()

Protected method to open the configuration dialog.

#### ProjectBaseBrowser._connectExpandedCollapsed

_connectExpandedCollapsed()

Protected method to connect the expanded and collapsed signals.

#### ProjectBaseBrowser._contextMenuRequested

_contextMenuRequested(coord)

Protected slot to show the context menu.

coord (QPoint)
  the position of the mouse pointer

#### ProjectBaseBrowser._copyToClipboard

_copyToClipboard()

Protected method to copy the path of an entry to the clipboard.

#### ProjectBaseBrowser._createPopupMenus

_createPopupMenus()

Protected overloaded method to generate the popup menus.

#### ProjectBaseBrowser._deleteDirectory

_deleteDirectory()

Protected method to delete the selected directory from the project data area.

#### ProjectBaseBrowser._disconnectExpandedCollapsed

_disconnectExpandedCollapsed()

Protected method to disconnect the expanded and collapsed signals.

#### ProjectBaseBrowser._expandAllDirs

_expandAllDirs()

Protected slot to handle the 'Expand all directories' menu action.

#### ProjectBaseBrowser._initHookMethods

_initHookMethods()

Protected method to initialize the hooks dictionary.

This method should be overridden by subclasses. All supported hook methods should be initialized with a None value. The keys must be strings.

#### ProjectBaseBrowser._initMenusAndVcs

_initMenusAndVcs()

Protected slot to initialize the menus and the Vcs interface.

#### ProjectBaseBrowser._keyboardSearchType

_keyboardSearchType(item)

Protected method to check, if the item is of the correct type.

item (BrowserItem)
  reference to the item

Return:
  flag indicating a correct type

Return Type:
  bool

#### ProjectBaseBrowser._newProject

_newProject()

Protected slot to handle the newProject signal.

#### ProjectBaseBrowser._prepareRepopulateItem

_prepareRepopulateItem(name)

Protected slot to handle the prepareRepopulateItem signal.

name (str)
  relative name of file item to be repopulated

#### ProjectBaseBrowser._projectClosed

_projectClosed()

Protected slot to handle the projectClosed signal.

#### ProjectBaseBrowser._projectOpened

_projectOpened()

Protected slot to handle the projectOpened signal.

#### ProjectBaseBrowser._removeDir

_removeDir()

Protected method to remove a (single) directory from the project.

#### ProjectBaseBrowser._removeFile

_removeFile()

Protected method to remove a file or files from the project.

#### ProjectBaseBrowser._renameFile

_renameFile()

Protected method to rename a file of the project.

#### ProjectBaseBrowser._selectEntries

_selectEntries(local=True, filterList=None)

Protected method to select entries based on their VCS status.

local (boolean))
  flag indicating local (i.e. non VCS controlled) file/directory entries should be selected
filterList (Class)
  list of classes to check against

#### ProjectBaseBrowser._selectSingleItem

_selectSingleItem(index)

Protected method to select a single item.

index (QModelIndex)
  index of item to be selected

#### ProjectBaseBrowser._setItemRangeSelected

_setItemRangeSelected(startIndex, endIndex, selected)

Protected method to set the selection status of a range of items.

startIndex (QModelIndex)
  start index of range of items to set
endIndex (QModelIndex)
  end index of range of items to set
selected (bool)
  flag giving the new selection status

#### ProjectBaseBrowser._setItemSelected

_setItemSelected(index, selected)

Protected method to set the selection status of an item.

index (QModelIndex)
  index of item to set
selected (bool)
  flag giving the new selection status

#### ProjectBaseBrowser._showContextMenu

_showContextMenu(menu)

Protected slot called before the context menu is shown.

It enables/disables the VCS menu entries depending on the overall VCS status and the file status.

menu (QMenu)
  reference to the menu to be shown

#### ProjectBaseBrowser._showContextMenuBack

_showContextMenuBack(_menu)

Protected slot called before the context menu is shown.

_menu (QMenu)
  reference to the menu to be shown (unused)

#### ProjectBaseBrowser._showContextMenuDir

_showContextMenuDir(menu)

Protected slot called before the context menu is shown.

It enables/disables the VCS menu entries depending on the overall VCS status and the directory status.

menu (QMenu)
  reference to the menu to be shown

#### ProjectBaseBrowser._showContextMenuDirMulti

_showContextMenuDirMulti(menu)

Protected slot called before the context menu is shown.

It enables/disables the VCS menu entries depending on the overall VCS status and the directory status.

menu (QMenu)
  reference to the menu to be shown

#### ProjectBaseBrowser._showContextMenuMulti

_showContextMenuMulti(menu)

Protected slot called before the context menu (multiple selections) is shown.

It enables/disables the VCS menu entries depending on the overall VCS status and the files status.

menu (QMenu)
  reference to the menu to be shown

#### ProjectBaseBrowser._showProjectInFileManager

_showProjectInFileManager()

Protected slot to show the path of the project in a file manager application.

#### ProjectBaseBrowser.addHookMethod

addHookMethod(key, method)

Public method to add a hook method to the dictionary.

key (str)
  for the hook method
method (function)
  reference to the hook method

#### ProjectBaseBrowser.addHookMethodAndMenuEntry

addHookMethodAndMenuEntry(key, method, menuEntry)

Public method to add a hook method to the dictionary.

key (str)
  for the hook method
method (function)
  reference to the hook method
menuEntry (str)
  entry to be shown in the context menu

#### ProjectBaseBrowser.currentDirectory

currentDirectory(relative=False)

Public method to determine the directory of the currently selected entry.

relative (bool)
  flag indicating to return the directory as a relative path

Return:
  directory of the current entry

Return Type:
  str

#### ProjectBaseBrowser.currentItem

currentItem()

Public method to get a reference to the current item.

Return:
  reference to the current item

Return Type:
  BrowserItem

#### ProjectBaseBrowser.expandItemsByName

expandItemsByName(names)

Public method to expand items given their names.

names (list of str)
  list of item names to be expanded

#### ProjectBaseBrowser.getExpandedItemNames

getExpandedItemNames()

Public method to get the file/directory names of all expanded items.

Return:
  list of expanded items names

Return Type:
  list of str

#### ProjectBaseBrowser.removeHookMethod

removeHookMethod(key)

Public method to remove a hook method from the dictionary.

key (str)
  for the hook method

#### ProjectBaseBrowser.selectFile

selectFile(fn)

Public method to highlight a node given its filename.

fn (str)
  filename of file to be highlighted

#### ProjectBaseBrowser.selectFileLine

selectFileLine(fn, lineno)

Public method to highlight a node given its filename.

fn (str)
  filename of file to be highlighted
lineno (int)
  one based line number of the item

#### ProjectBaseBrowser.selectLocalDirEntries

selectLocalDirEntries()

Public slot to handle the select local directories context menu entries.

#### ProjectBaseBrowser.selectLocalEntries

selectLocalEntries()

Public slot to handle the select local files context menu entries.

#### ProjectBaseBrowser.selectVCSDirEntries

selectVCSDirEntries()

Public slot to handle the select VCS directories context menu entries.

#### ProjectBaseBrowser.selectVCSEntries

selectVCSEntries()

Public slot to handle the select VCS files context menu entries.

Up